<pre class='metadata'>
Title: CSS Shapes Module Level 1
Status: ED
Prepare for TR: no
Work Status: Testing
Shortname: css-shapes
Level: 1
Group: csswg
TR: https://www.w3.org/TR/css-shapes/
ED: https://drafts.csswg.org/css-shapes/
Previous Version: https://www.w3.org/TR/2025/CRD-css-shapes-1-20250612/
Editor: Rossen Atanassov, Microsoft Corporation, ratan@microsoft.com, w3cid 49885
Editor: Alan Stearns, Adobe, stearns@adobe.com, w3cid 46659
Editor: Noam Rosenthal, Google, w3cid 121539
Former Editor: Vincent Hardy
Implementation Report: https://wpt.fyi/results/css/css-shapes
Abstract: CSS Shapes describe geometric shapes for use in CSS. For Level 1, CSS Shapes can be applied to floats. A circle shape on a float will cause inline content to <a>wrap</a> around the circle shape instead of the float's bounding box.
Repository: w3c/csswg-drafts
WPT Path Prefix: css/css-shapes/
WPT Display: open
</pre>

<pre class='link-defaults'>
spec:css2; type:property; text:margin
spec:css-backgrounds-3; type:property; text:border-radius
spec:css-inline; type:dfn; text:initial letter box
spec:css-masking-1; type: value
	text: nonzero
	text: evenodd
spec:css-shapes; type: value
	text: closest-side
	text: farthest-side
spec:svg2; type:property; 
	text:fill-rule
spec:css-values-5; type:value;
	text:top;
	text:right;
	text:bottom;
	text:left;
	text:center;
	text:x-start;
	text:y-start;
	text:x-end;
	text:y-end;
</pre>

<style>
	.singleImgExample {
		display: block;
		margin: auto;
	}
</style>

<h2 id="intro">
Introduction</h2>

<em>This section is not normative.</em>

	Shapes define arbitrary geometries
	that can be used as CSS values.
	This specification defines properties
	to control the geometry
	of an element's <a>float area</a>.
	The 'shape-outside' property uses shape values
	to define the <a>float area</a> for a float.

	Note: Future levels of CSS Shapes will allow use of shapes
	on elements other than floats.
	Other CSS modules can make use of shapes as well,
	such as CSS Masking [[CSS-MASKING]]
	and CSS Exclusions [[CSS3-EXCLUSIONS]].

	Note: If a user agent implements both CSS Shapes
	and CSS Exclusions,
	the 'shape-outside' property defines
	the exclusion area for an exclusion.

	Note: A future level of CSS Shapes will define a shape-inside property,
	which will define a shape to <a>wrap</a> content within the element.

<h3 id="module-interactions">
Module Interactions</h3>

	This module extends the float features defined in [[!CSS2]] chapter 9.

<h3 id="values">Values</h3>


	This specification follows the <a href="https://www.w3.org/TR/CSS2/about.html#property-defs">CSS property definition conventions</a> from [[!CSS2]]
	using the <a href="https://www.w3.org/TR/css-values-3/#value-defs">value definition syntax</a> from [[!CSS-VALUES-3]].
	Value types not defined in this specification are defined in CSS Values &amp; Units [[!CSS-VALUES-3]].
	Combination with other CSS modules may expand the definitions of these value types.

	In addition to the property-specific values listed in their definitions,
	all properties defined in this specification
	also accept the <a>CSS-wide keywords</a> as their property value.
	For readability they have not been repeated explicitly.

<h3 id="terminology">
Terminology</h3>

	<dfn data-lt="wrap|wrapping">Wrap</dfn>

	This specification uses the term <a>wrap</a>
	to refer to flowing content
	around the sides of a <a>float area</a>,
	defined in [[!CSS2]] chapter 9.
	Content <a>wraps</a> around the right side
	of a left-floated box,
	and content <a>wraps</a> around the left side
	of a right-floated box.
	One result of this <a>wrapping</a>
	is that line boxes next to a float
	are shortened as necessary
	to avoid intersections with the <a>float area</a>.

	<dfn>Float area</dfn>

	The area used
	for <a>wrapping</a> content
	around a float element.
	The rules for float behavior
	use the sides of the <a>float area</a>
	to determine where content flows.
	By default,
	the <a>float area</a> is the float element's
	<a>margin box</a>
	(note this can be different than
	the <a>float area</a> produced
	by the ''margin-box'' value,
	which includes border-radius curvature).
	This specification's 'shape-outside' 
	and 'shape-margin' properties
	can be used to define an arbitrary,
	non-rectangular <a>float area</a>.

	<dfn>direction-agnostic size</dfn>
	The [=direction-agnostic size=] of a box is equal to the length of the diagonal of the box,
	divided by sqrt(2).

	Note: This is a method of averaging the width and height of a box
	used by SVG in some cases,
	when a percentage of a box's size is desired
	but the context doesn't specifically favor the width or the height.
	For square boxes, this is the same as the width/height.

<h2 id="relation-to-box-model-and-float-behavior">
Relation to the box model and float behavior</h2>

	While the boundaries used
	for <a>wrapping</a> inline flow content
	outside a float
	can be defined using shapes,
	the actual box model does not change.
	If the element has specified
	margins, borders or padding
	they will be computed and rendered
	according to the [[!CSS3BOX]] module.
	Also, float positioning and stacking are not affected
	by defining a <a>float area</a> with a shape.

	When a shape is used to define
	a <a>float area</a>,
	the shape is clipped
	to the float's margin box.
	In other words,
	a shape can only ever reduce
	a <a>float area</a>,
	not increase it.
	A reduced <a>float area</a> may have no effect
	on some line boxes
	that would normally be affected by the float.
	If a shape does not enclose any area, 
	the shape’s edges are still used 
	to define the <a>float area</a>.

	A <a>float area</a> defined by a shape
	may reduce the normal <a>float area</a> on all sides,
	but this does not allow content to <a>wrap</a>
	on both sides of a float.
	Left floats with a 'shape-outside' still
	only allow content <a>wrapping</a> on the right side,
	and right floats only allow <a>wrapping</a> on the left.

	<div class="example">

		In the following example
		the left and right floating
		<code class="html">img</code> elements
		specify a triangular shape
		using the 'shape-outside' property.

		<pre><code>
			&lt;img class="left" src="hand.svg"/&gt;
			&lt;img class="right" src="hand.svg"/&gt;
			&lt;p&gt;
				Sometimes a web page's text content appears to be
				funneling your attention towards a spot on the page
				to drive you to follow a particular link. Sometimes
				you don't notice.
			&lt;/p&gt;

			&lt;style type="text/css"&gt;
				.left {
					shape-outside: polygon(0 0, 100% 100%, 0 100%);
					float: left;
					width: 40%;
					height: 12ex;
					transform: scaleX(-1);
				}

				.right {
					shape-outside: polygon(100% 0, 100% 100%, 0 100%);
					float: right;
					width: 40%;
					height: 12ex;
				}

				p {
					text-align: center;
				}
			&lt;/style&gt;
		</code>
		</pre>

		<img class="singleImgExample" src="images/hand-funnel.png" alt="Using the shape-outside property with floats">
	</div>

	<div class="example">

		Since shapes are clipped to the float's margin box,
		adding this shape to the left float above
		would result in the same rendering.

		<pre><code>
			shape-outside: polygon(0 0, 500% 500%, 0 500%);
		</code>
		</pre>
	</div>

	<div class="example">

		A shape that does not enclose any area
		still has edges that contribute to the <a>float area</a>.

		This inset shape is a vertical line positioned 
		at the midpoint of the reference box. 
		This midpoint edge is used as the edge 
		of the float area for wrapping content.
		<pre><code>
			shape-outside: inset(0% 50% 0% 50%);
		</code></pre>

		If inset values add up to more than the width, 
		[[css-backgrounds-3#corner-overlap]] rules are used to determine 
		the edges of the rectangle. 
		This shape results in a vertical edge 
		25% from the left side of the reference box.
		<pre><code>
			shape-outside: inset(0% 150% 50% 0%);
		</code></pre>

		If the shape is only a horizontal line, 
		then it is an empty float area and has no effect on wrapping. 
		Note that in this example shape-margin must be 0px 
		(otherwise the line would expand to enclose an area).
		<pre><code>
			shape-outside: inset(50% 0% 0% 50%);
			shape-margin: 0px;
		</code></pre>
	</div>

	<div class="example">

		A 'shape-outside' can create open areas
		on both the left and right
		of a <a>float area</a>.
		Content still <a>wraps</a> only on one side
		of a float in this case.
		In the picture,
		the shape is rendered in blue,
		and the content area outside the shape in mauve.

		<pre><code>
			shape-outside: polygon(50px 0px, 100px 100px, 0px 100px);
		</code>
		</pre>
		<img class="singleImgExample" src="images/float-side-example.png" alt="wrapping around right side of a left-float float area">
	</div>

	<div class="example">

		The following styling creates
		a shape much smaller than
		the float's content area,
		and adds a margin-top to the float.
		In the picture,
		the shape is rendered in blue,
		the content area outside the shape in mauve,
		and the margin area of the float box in yellow.
		The inline content only <a>wraps</a> around the shape,
		and otherwise overlays the rest
		of the float margin box.

		<pre><code>
			.float-left {
				shape-outside: polygon(0% 50%, 50% 100%, 0 100%);
				float: left;
				width: 100px;
				height: 100px;
				margin-top: 20px;
			}
		</code></pre>

		<img class="singleImgExample" src="images/float-margin-example.png" alt="Adding margin-top to a float with a small shape-outside">

		The next picture shows a possible result
		if two of these floats
		were stacked next to each other.
		Note that the floats are positioned
		using their margin boxes,
		not the <a>float area</a>.

		<img class="singleImgExample" src="images/stacked-float-example.png" alt="Stacking two floats with a small shape-outside">
	</div>

<h2 id="basic-shape-functions">
Basic Shapes</h2>

	The <dfn>&lt;basic-shape&gt;</dfn> type
	can be specified using basic shape functions.
	When using this syntax
	to define shapes,
	the <dfn for="<basic-shape>" export>reference box</dfn> is defined
	by each property that uses
	<<basic-shape>> values.
	The coordinate system for the shape
	has its origin on the top-left corner of the
	<a>reference box</a> with the x-axis
	running to the right
	and the y-axis running downwards.
	All the lengths expressed in percentages
	are resolved from the used dimensions
	of the <a>reference box</a>.

<h3 id="supported-basic-shapes">
Supported Shapes</h3>

	The <<basic-shape>> functions are:

	<pre class=prod>
		<<inset()>> = inset(
			<<length-percentage>>{1,4}
			[ round <<'border-radius'>> ]?
		)

		<<xywh()>> = xywh(
			<<length-percentage>>{2} <<length-percentage [0, ∞]>>{2}
			[ round <<'border-radius'>> ]?
		)

		<<rect()>> = rect(
			[ <<length-percentage>> | auto ]{4}
			[ round <<'border-radius'>> ]?
		)

		<dfn>&lt;basic-shape-rect></dfn> = <<inset()>> | <<rect()>> | <<xywh()>>

		<<circle()>> = circle(
			<<radial-size>>?
			[ at <<position>> ]?
		)

		<<ellipse()>> = ellipse(
			<<radial-size>>?
			[ at <<position>> ]?
		)

		<<polygon()>> = polygon(
			<<'fill-rule'>>? 
			[ round <<length>> ]? ,
			[<<length-percentage>> <<length-percentage>>]#
		)

		<<path()>> = path(
			<<'fill-rule'>>? ,
			<<string>>
		)

		<<shape()>> = shape(
			<<'fill-rule'>>?
			from <<position>> ,
			<<shape-command>>#
		)
	</pre>


	<dl dfn-for="<basic-shape>">
		<dt><dfn>inset()</dfn>
		<dd>
			Defines an inset rectangle
			via insets from each edge of the [=reference box=].

			If less than four <<length-percentage>> values are provided,
			the omitted values default in the same way as the 'margin' shorthand:
			an omitted second or third value defaults to the first,
			and an omitted fourth value defaults to the second.

			The four <<length-percentage>>s
			define the position of the top, right, bottom, and left edges of a rectangle,
			respectively,
			as insets from the corresponding edges of the [=reference box=].

			A pair of insets in either dimension
			that add up to more than the used dimension
			(such as left and right insets of 75% apiece)
			use the [[css-backgrounds-3#corner-overlap]] rules 
			to proportionally reduce the inset effect to 100%.

			<div class=example>
				For example, specifying ''inset(75% 0 50% 0)''
				has the top+bottom edges summing to 125%
				of the [=reference box's=] height.
				They're proportionally reduced to sum to 100%,
				identical to specifying ''inset(60% 0 40% 0)''.
			</div>

			The optional <<'border-radius'>> argument(s)
			define rounded corners for the rectangle
			using the 'border-radius' shorthand syntax.

			<wpt>
				shape-functions/inset-function-computed.html
				shape-functions/inset-function-invalid.html
				shape-functions/inset-function-valid.html
			</wpt>

		<dt><dfn>xywh()</dfn>
		<dd>
			Defines a rectangle
			via offsets from the top and left edge of the [=reference box=],
			and a specified width and height.

			The four <<length-percentage>>s define,
			respectively,
			the inset from the left edge of the [=reference box=],
			the inset from the top edge of the [=reference box=],
			the width of the rectangle,
			and the height of the rectangle.

			Note: This syntax is inspired by the <{svg/viewBox}> attribute from SVG.

			The optional <<'border-radius'>> argument(s)
			define rounded corners for the inset rectangle
			using the 'border-radius' shorthand syntax.

			<wpt>
				shape-functions/xywh-function-computed.html
				shape-functions/xywh-function-invalid.html
				shape-functions/xywh-function-valid.html
			</wpt>

		<dt><dfn>rect()</dfn> =
		<dd>
			Defines a rectangle
			via insets from the top and left edges of the [=reference box=].

			The four <<length-percentage>>s
			define the position of the top, right, bottom, and left edges of a rectangle,
			respectively,
			as insets from the top edge of the [=reference box=]
			(for the first and third values)
			or the left edge of the [=reference box=]
			(for the second and fourth values).

			An <css>auto</css> value makes the edge of the box
			coincide with the corresponding edge of the [=reference box=]:
			it's equivalent to ''0%''
			as the first (top) or fourth (left) value,
			and equivalent to ''100%''
			as the second (right) or third (bottom) value.

			The second (right) and third (bottom) values are floored
			by the fourth (left) and second (top) values, respectively.

			<div class='example'>
				For example, specifying ''rect(10px 0 0 20px)''
				would place the bottom edge higher than the top edge,
				and the right edge further left than the left edge,
				so both are corrected to not cross over the other edge,
				identical to specifying ''rect(10px 20px 10px 20px)''.
			</div>

			Note: This syntax is similar,
			but not quite identical,
			to the legacy ''rect()'' function
			used solely by the 'clip' property.

			The optional <<'border-radius'>> argument(s)
			define rounded corners for the rectangle
			using the 'border-radius' shorthand syntax.)

			<wpt>
				shape-functions/rect-function-computed.html
				shape-functions/rect-function-invalid.html
				shape-functions/rect-function-valid.html
			</wpt>

		<dt><dfn>circle()</dfn>
		<dd>
			* The <<radial-size>> argument defines
				the circle's radius.
				Rather than referring to the [=gradient box=],
				values are resolved against the [=reference box=].
				Two <<length-percentage>> values are invalid.
				If omitted it defaults to ''<radial-size>/closest-side''.

			* The <<position>> argument defines
				the center of the circle.
				Unless otherwise specified,
				this defaults to <css>center</css> if omitted.

			<wpt>
				shape-functions/circle-function-computed.html
				shape-functions/circle-function-invalid.html
				shape-functions/circle-function-valid.html
			</wpt>

		<dt><dfn>ellipse()</dfn>
		<dd>
			* The <<radial-size>> argument defines
				the horizontal and vertical radiuses of the ellipse.
				Rather than referring to the [=gradient box=],
				values are resolved against the [=reference box=].
				If omitted it defaults to ''<radial-size>/closest-side''.

			* The <<position>> argument defines
				the center of the ellipse.
				Unless otherwise specified,
				this defaults to <css>center</css> if omitted.

			<wpt>
				shape-functions/ellipse-function-computed.html
				shape-functions/ellipse-function-invalid.html
				shape-functions/ellipse-function-valid.html
			</wpt>

		<dt><dfn>polygon()</dfn>
		<dd>
			* The <<'fill-rule'>> specifies the filling rule used
				to determine the interior.
				Defaults to ''nonzero'' if omitted.

			* An optional <<length>> after a <css>round</css> keyword 
				defines rounding for each vertex of the polygon.
				The length is the radius of a circle 
				whose center lies on the bisector 
				of the smaller angle of the vertex,
				and that is tangential 
				to both sides of the vertex.

				<div class="example">
					<figure>
						<img src="images/vertex-rounding.png" alt="rounding concave and convex polygon vertices">
						<figcaption>
							Rounding polygon vertices that are both convex and concave.
						</figcaption>
					</figure>
				</div>

				To avoid rounding more
				than half of any line segment,
				the rounding of each vertex 
				must be clamped separately 
				such that the radius is never more than 
				the smaller of <code>tan(angle/2) segment / 2</code> 
				evaluated against both vertex line segments.

				<div class="example">
					<figure>
						<img src="images/clamp-explanation.png" alt="visualization of clamp formula">
						<figcaption>
							This diagram shows the intent of the clamping formula.
						</figcaption>
					</figure>
				</div>

			* Each <<length-percentage>> pair
				specifies a vertex of the polygon,
				as a horizontal and vertical offset
				from the left and top edges of the [=reference box=].

			The UA must close a polygon
			by connecting the last vertex
			with the first vertex of the list.

			<wpt>
				shape-functions/polygon-function-computed.html
				shape-functions/polygon-function-invalid.html
				shape-functions/polygon-function-valid.html
			</wpt>

		<dt><dfn>path()</dfn>
		<dd dfn-type=value dfn-for="path()">
			* The <<'fill-rule'>> specifies the filling rule used
				to determine the interior.
				Defaults to ''nonzero'' if omitted,
				unless the function is being used 
				in a context such as SVG shapes 
				where the 'fill-rule' property is relevant. 
				In that case an omitted value will use 
				the computed value of the 'fill-rule' property.

			* The <<string>> represents an
				<a href="https://www.w3.org/TR/SVG11/paths.html#PathData">SVG Path data string</a>.
				A path data string that does not conform to the
				to the grammar and parsing rules of SVG 1.1,
				or that does conform but defines an empty path,
				is [=invalid=] and causes the entire ''path()'' to be [=invalid=].

				The initial position is defined
				by the first “move to” argument
				in the path string.
				For the initial direction follow SVG 1.1.

			The UA must close a path 
			with an implicit 
			closepath command ("z" or "Z") 
			if it is not present in the string 
			for properties that require a closed loop 
			(such as 'shape-outside' and 'clip-path').

			<wpt>
				shape-functions/path-function-computed.html
				shape-functions/path-function-invalid.html
				shape-functions/path-function-valid.html
			</wpt>

		<dt><dfn>shape()</dfn>
		<dd dfn-type=value dfn-for="shape()">
			See <a href="#shape-function">The shape() function</a>.

			<wpt>
				shape-functions/shape-function-computed.html
				shape-functions/shape-function-invalid.html
				shape-functions/shape-function-valid.html
			</wpt>
	</dl>

<h4 id='shape-function'>
The ''shape()'' Function</h4>

	While the ''path()'' function allows reuse of the SVG path syntax
	to define more arbitrary shapes than allowed by more specialized shape functions,
	it requires writing a path as a single string
	(which is not compatible with, for example, building a path piecemeal with ''var()''),
	and inherits a number of limitations from SVG,
	such as implicitly only allowing the ''px'' unit.

	The ''shape()'' function uses a set of commands roughly equivalent to the ones used by ''path()'',
	but does so with more standard CSS syntax,
	and allows the full range of CSS functionality,
	such as additional units and math functions.
	The commands used by ''shape()'' are dynamically turned into path segments when it is used for rendering,
	e.g., when computing the rendered 'clip-path'.

	In that sense, ''shape()'' is a superset of ''path()''. A ''path()'' can be easily converted to a ''shape()'',
	but to convert a ''shape()'' back to a ''path()'' or to SVG requires information about the CSS environment (e.g.
	current values of CSS custom properties, current font size for ''em'' units, etc).

	The <<'fill-rule'>> is interpreted identically to the same argument in ''path()''.

	The rest of the arguments define a list of path data commands,
	identical to that of an <a href="https://www.w3.org/TR/SVG11/paths.html#PathData">SVG Path</a>,
	which the function represents.

	The <css>from <<coordinate-pair>></css> represents the starting point for the first shape-command.
	It adds an initial <a href="https://www.w3.org/TR/SVG/paths.html#PathDataMovetoCommands">absolute moveto</a>
	to the list of path data commands.

	The sequence of <dfn><<shape-command>></dfn>s represent
	further <a href="https://www.w3.org/TR/SVG11/paths.html#PathData">path data commands</a>.
	Each command's starting point is the previous command's ending point.

	<pre class=prod>
		<<shape-command>> = <<move-command>> | <<line-command>> | close |
		                  <<horizontal-line-command>> | <<vertical-line-command>> |
		                  <<curve-command>> | <<smooth-command>> | <<arc-command>>

		<<move-command>> = move <<command-end-point>>
		<<line-command>> = line <<command-end-point>>
		<<horizontal-line-command>> = hline
						[ to [ <<length-percentage>> | left | center | right | x-start | x-end ]
						| by <<length-percentage>> ]
		<<vertical-line-command>> = vline
						[ to [ <<length-percentage>> | top | center | bottom | y-start | y-end ]
						| by <<length-percentage>> ]
		<<curve-command>> = curve
						[ [ to <<position>> with <<control-point>> [ / <<control-point>> ]? ]
						| [ by <<coordinate-pair>> with <<relative-control-point>> [ / <<relative-control-point>> ]? ] ]
		<<smooth-command>> = smooth
						[ [ to <<position>> [ with <<control-point>> ]? ]
						| [ by <<coordinate-pair>> [ with <<relative-control-point>> ]? ] ]
		<<arc-command>> = arc <<command-end-point>>
								[ [ of <<length-percentage>>{1,2} ]
								  && <<arc-sweep>>? && <<arc-size>>? && [rotate <<angle>>]? ]

		<<command-end-point>> = [ to <<position>> | by <<coordinate-pair>> ]
		<<control-point>> = [ <<position>> | <<relative-control-point>> ]
		<<relative-control-point>> = <<coordinate-pair>> [ from [ start | end | origin ] ]?
		<<coordinate-pair>> = <<length-percentage>>{2}
		<<arc-sweep>> = cw | ccw
		<<arc-size>> = large | small
	</pre>

	<dl dfn-for="shape()">
		<dt><dfn><<coordinate-pair>></dfn> = <<length-percentage>>{2}
		<dd>Defines a pair of coordinates,
			representing a rightward and downward offset, respectively,
			from a specified reference point.
			Percentages are resolved against the width or height, respectively,
			of the [=reference box=].

		<dt><dfn><<command-end-point>></dfn> = [ <dfn value for="shape(), <command-end-point>">to</dfn> <<position>> | <dfn value for="shape(), <command-end-point>">by</dfn> <<coordinate-pair>> ]
		<dd>
			Every command can be specified in "absolute" or "relative" coordinates,
			determined by their ''shape()/by'' or ''shape()/to'' component.
			''shape()/to'' indicates that any <<coordinate-pair>>s in the command
			are relative to the top-left corner of the [=reference box=],
			while ''shape()/by'' indicates that the <<coordinate-pair>>s
			are relative to the command's starting point.

			<<relative-control-point>> defines how ''shape()/by'' and ''shape()/to'' are interpreted for curve control points,
			while <<horizontal-line-command>> and <<vertical-line-command>> define how ''shape()/by'' and ''shape()/to'' are
			interpreted for horizontal and vertical lines, respectively.

			When ''shape()/to'' is used, the coordinates can be specified as <<position>>s instead of <<coordinate-pair>>s.

			Note: In either case, <<percentage>> values in <<coordinate-pair>>s
			are always computed relative to the [=reference box's=] size.

		<dt><dfn><<move-command>></dfn> = <dfn value>move</dfn> <<command-end-point>>
		<dd>
			Adds a <a href="https://www.w3.org/TR/SVG/paths.html#PathDataMovetoCommands">moveto</a> command
			to the list of path data commands,
			with an ending point specified by the <<coordinate-pair>>.

			This draws nothing,
			and merely "moves the pen" for the next command.

			Note: This starts a new subpath,
			for the purpose of the ''close'' command.

		<dt><dfn><<line-command>></dfn> = <dfn value>line</dfn> <<command-end-point>>
		<dd>
			Adds a <a href="https://www.w3.org/TR/SVG/paths.html#PathDataLinetoCommands">lineto</a> command
			to the list of path data commands,
			with an ending point specified by the <<coordinate-pair>>.

			This draws a straight line from the command's starting point to its ending point.

		<dt><dfn><<horizontal-line-command>></dfn> = hline [ to [ <<length-percentage>> | left | center | right | x-start | x-end ]
															| by <<length-percentage>> ]
		<dd>
			Adds a horizontal
			<a href="https://www.w3.org/TR/SVG/paths.html#PathDataLinetoCommands">lineto</a> command
			to the list of path data commands.

			This is equivalent to a ''line'' command
			with the <<length-percentage>> given as the horizontal component of the <<coordinate-pair>>.
			Specifying the horizontal component of <<position>> instead of a <<length-percentage>> (''left'', ''center'', ''right'', ''x-start'', or ''x-end''),
			would draw a line to that <<position>>, with the <<position>>'s vertical component remaining the same as the starting point.

		<dt><dfn><<vertical-line-command>></dfn> = vline [ to [ <<length-percentage>> | top | center | bottom | y-start | y-end ] | by <<length-percentage>> ]
		<dd>
			Adds a vertical
			<a href="https://www.w3.org/TR/SVG/paths.html#PathDataLinetoCommands">lineto</a> command
			to the list of path data commands.

			This is equivalent to a ''line'' command
			with the <<length-percentage>> given as the vertical component of the <<coordinate-pair>>.
			Specifying the horizontal component of <<position>>
			(''top'', ''center'', ''bottom'', ''y-start'', or ''y-end'')
			instead of a <<length-percentage>>,
			would draw a line to that <<position>>, with the <<position>>'s horizontal component remaining the same as the starting point.

		<dt><dfn><<curve-command>></dfn> = <dfn value>curve</dfn> [ [ to <<position>> with <<control-point>> [ / <<control-point>> ]? ]
						| [ by <<coordinate-pair>> with <<relative-control-point>> [ / <<relative-control-point>> ]? ] ]
		<dd>
			Adds a Bézier curve command to the list of path data commands,
			ending at the point specified by the <<position>> following the ''shape()/to'' keyword,
			or the <<coordinate-pair>> following the ''shape()/by'' keyword, as specified by <<command-end-point>>.

			The <css>with</css> component specifies control points for the curve:
			if a single <<control-point>> or <<relative-control-point>> is provided,
			the command specifies a <a href="https://www.w3.org/TR/SVG/paths.html#PathDataQuadraticBezierCommands">quadratic curve</a>;
			if two  <<control-point>>s or <<relative-control-point>>s are provided,
			it specifies a <a href="https://www.w3.org/TR/SVG/paths.html#PathDataCubicBezierCommands">cubic curve</a>.

		<dt><dfn><<smooth-command>></dfn> = <dfn value>smooth</dfn> [ [ to <<position>> [with <<control-point>> ]? ]
						| [ by <<coordinate-pair>> [ with <<relative-control-point>> ]? ] ]
		<dd>
			Adds a smooth Bézier curve command to the list of path data commands,
			ending at the point specified by the <<position>> following the ''shape()/to'' keyword, or the <<coordinate-pair>> following the ''shape()/by'' keyword, as specified by <<command-end-point>>.
			The <css>with</css> component specifies control points for the curve:
			if it's omitted,
			the command specifies a <a href="https://www.w3.org/TR/SVG/paths.html#PathDataQuadraticBezierCommands">smooth quadratic curve</a>;
			if it's provided,
			if specifies a <a href="https://www.w3.org/TR/SVG/paths.html#PathDataCubicBezierCommands">smooth cubic curve</a>.

			Note: A ''smooth'' command is equivalent to a ''curve'' command
			with the first control point automatically specified
			as the reflection of the previous curve's second control point
			around the starting point,
			or as the starting point if the previous path data command wasn't a curve.
			This ensures G1 continuity with the previous command,
			so the curve appears to smoothly continue from the previous command,
			rather than possibly making a sudden direction change.

		<dt><dfn><<control-point>></dfn> = [ <<position>> | <<relative-control-point>> ]
		<dd>
			Provides a control point to a quadratic or cubic Bézier curve.

		<dt><dfn><<relative-control-point>></dfn> = <<coordinate-pair>> [ from [ start | end | origin ] ]?
		<dd>
			Provides a control point to a quadratic or cubic Bézier curve.
			When a <css>from</css> keyword is specified followed by <css>start</css>, <css>end</css>, or <css>origin</css>,
			the given <<coordinate-pair>> is relative to
			the command's starting point, the command's end point, or the [=reference box=], respectively.
			If such component is not provided, the <<coordinate-pair>> is relative to the segment's start.

		<dt><dfn><<arc-command>></dfn> = <dfn value>arc</dfn> <<command-end-point>> [of <<length-percentage>>{1,2}] && <<arc-sweep>>? && <<arc-size>>? && rotate <<angle>>? ]
		<dd>
			Add an <a href="https://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands">elliptical arc</a> command
			to the list of path data commands,
			ending at the <<command-end-point>>.

			The <css>of</css> component specifies the size of the ellipse that the arc is taken from.
			The first <<length-percentage>> provides the horizontal radius of the ellipse
			and the second provides the vertical radius.
			Like for <<coordinate-pair>>s,
			<<percentage>> values are resolved against the width or height of the [=reference box=],
			as appropriate.

			If only one <<length-percentage>> is provided,
			both radiuses use the provided value.
			In that case, <<percentage>> values are resolved against the [=direction-agnostic size=] of the [=reference box=]
			(similar to the ''circle()'' function).

			<div class=note>
				Note that SVG has [[svg2#ArcOutOfRangeParameters|some specific error-handling for the ellipse radiuses]]:

				* if the endpoint is the same as the starting point, the command does nothing
				* if either radius is zero, the command is equivalent to a <<line-command>> to the ending point
				* if either radius is negative, its absolute value is used instead
				* if the radiuses don't describe an ellipse large enough
					to intersect both the starting point and ending point
					(after rotation by the specified <<angle>>),
					they are scaled up uniformly until the ellipse is just large enough to reach.
			</div>

			The ellipse described by the specified radiuses defaults to being axis-aligned,
			but can be rotated by specifying an <<angle>>.
			Similar to the ''rotate()'' transform function,
			positive angles specify a clockwise rotation,
			and negative angles specify a counterclockwise rotation.
			If omitted, this defaults to ''0deg''.

			The ending point, radiuses, and angle,
			taken together,
			usually define two possible ellipses
			that intersect the starting point and ending point,
			and each ellipse can be traced in either direction,
			for a total of four possible arcs.
			The <<arc-sweep>> and <<arc-size>> components specify which of these arcs is desired:

			* <dfn><<arc-sweep>></dfn> can be <dfn value for="shape(), arc">cw</dfn> or <dfn value for="shape(), arc">ccw</dfn>,
				indicating that the arc that is traced around the ellipse clockwise or counter-clockwise from the center, respectively,
				must be chosen.
				If omitted, this defaults to ''ccw''.

				Note: In the SVG arc command, ''cw'' corresponds to the value 1 for the sweep flag, and ''ccw'' to the value 0.

			* <dfn><<arc-size>></dfn> can be <dfn value for="shape(), arc">large</dfn> or <dfn value for="shape(), arc">small</dfn>,
				indicating that the larger or smaller, respectively, of the two possible arcs
				must be chosen.
				If omitted, this defaults to ''small''.

				Note: In the SVG arc command, ''large'' corresponds to the value 1 for the large flag, and ''small'' to the 0.

				Note: If the starting and ending points are on exactly opposite sides of the ellipse,
				both possible arcs are the same size,
				but also there is only one possible ellipse.
				In this case, the <<arc-sweep>> distinguishes which of the two possible arcs will be chosen,
				and <<arc-size>> has no effect.

			<figure>
				<img src="images/four-arcs.svg" alt="a depiction of four possible arcs given a start and end point">
				<figcaption>
					A depiction of the two possible ellipses,
					and four possible arcs,
					that can be chosen between.
				</figcaption>
			</figure>

		<dt><dfn value>close</dfn>
		<dd>
			Adds a <a href="https://www.w3.org/TR/SVG/paths.html#PathDataClosePathCommand">closepath</a> command
			to the list of path data commands.

			Note: This is similar to a ''line'' command
			with its ending point set to the starting point of the subpath.
			When specifying a raw shape, they're identical,
			but if the path is stroked,
			the ending point of the ''close'' command is smoothly joined
			with the start of the subpath,
			which affects how line-joins and line-caps are rendered.
	</dl>

<h5 id=shape-examples>Using ''shape()'' to create responsive, parametric speech bubble</h5>

<div class=example>
The ''shape()'' function enables shapes that are responsive, rather than scalable.
While the ''polygon()'' shape is also responsive, it only support simple rounded corners and not complex curves.

To demonstrate, let's start with a speech bubble, such as the following:

<img src="images/bubble.svg" width=300 style="background: unset" alt="A speech bubble shape">

Using this shape with a ''clip-path'' can be done by using the ''path()'' function:

<pre highlight="css">
.bubble { clip-path: path("m 5 0 H 95 Q 100 0 100 5 V 92 Q 100 97 95 97 H 70 l -2 3 l -2 -3 H 5 Q 0 97 0 92 V 5 Q 0 0 5 0") };
</pre>

Altohugh this path can easily scale, the scaled results are not always desirable. e.g. when scaled to a small balloon, the arrow and corners are scaled to become almost invisible:

<img src="images/bubble.svg" width=100 style="background: unset" alt="scled-down speech bubble shape">

To construct this shape using the ''shape()'' function, let's start by turning all the pixel values from the ''path'' function to percentages.
Note that the ''shape()'' function begins with <css>from</css>:

<pre highlight="css">
.bubble { clip-path: shape(	from 5% 0%,
							hline to 95%,
							curve to 100% 5% with 100% 0%,
							vline to 92%,
							curve to 95% 97% with 100% 97%,
							hline to 70%,
							line by -2% 3%,
							line by -2% -3%,
							hline to 5%,
							curve to 0% 92% with 0% 97%,
							vline to 5%,
							curve to 5% 0% with 0% 0%); }
</pre>

To make this path responsive, as in, respond well to size changes, we will convert some of its units to ''px'' values,
specifically the ones the control the curves and arrows:

<pre highlight="css">
.bubble { clip-path: shape(	from 5px 0%,
							hline to calc(100% - 5px),
							curve to 100% 5px with 100% 0%,
							vline to calc(100% - 8px),
							curve to calc(100% - 5px) calc(100% - 3px) with 100% calc(100% - 3px),
							hline to 70%,
							line by -2px 3px,
							line by -2px -3px,
							hline to 5px,
							curve to 0% calc(100% - 8px) with 0% calc(100% - 3px),
							vline to 5px,
							curve to 5px 0% with 0% 0%); }
</pre>

When applied as ''clip-path'', it would looks like the following:
<p>
<img src="images/bubble-50.svg" width=150 style="background: unset" alt="A speech bubble shape, using clip-path">
</p>

The whole speech bubble is scaled to the reference box, while the curves and arrows stay more constant.

Since ''shape()'' uses CSS units, we can replace some of the edges with ''position'' values:

<pre highlight="css">
.bubble { clip-path: shape(from 5px 0,
							hline to calc(100% - 5px),
							curve to right 5px with right top,
							vline to calc(100% - 8px),
							curve to calc(100% - 5px) calc(100% - 3px) with right calc(100% - 3px),
							hline to 70%,
							line by -2px 3px,
							line by -2px -3px,
							hline to 5px,
							curve to left calc(100% - 8px) with left calc(100% - 3px),
							vline to 5px,
							curve to 5px top with left top); }
</pre>

Another useful feature of ''shape()'' is that it can be used alongside CSS properties. In this case,
we can make the arrow and radius parametric:

<pre highlight="css">

:root {
	--radius: 5px;
	--arrow-length: 3px;
	--arrow-half-width: 2px;
	--arrow-position: 70%;
	--arrow-bottom-offset: calc(100% - var(--radius) - var(--arrow-length));
}

.bubble {
	animation: bubble 100ms;
	clip-path: shape(from var(---radius) top,
		hline to calc(100% - var(---radius)),
		curve to right var(---radius) with right top,
		vline to var(---arrow-bottom-offset),
		curve to calc(100% - var(---radius)) calc(100% - var(---arrow-length))
              with right calc(100% - var(---arrow-length)),
		hline to var(---arrow-position),
		line by var(---arrow-half-width) var(---arrow-length),
		line by var(---arrow-half-width) calc(0px - var(---arrow-length)),
		hline to var(---radius),
		curve to left var(---arrow-bottom-offset) with left calc(100% - var(---arrow-length)),
		vline to var(---radius),
		curve to var(---radius) top with left top); }
</pre>

</div>

<h5 id=interpolating-shape>
Interpolating the ''shape()'' Function</h5>

	''shape()'' and ''path()'' functions can be <l spec=css-values-4>[=interpolated=]</l> with each other
	if their associated list of path data commands is the same length
	and has the same commands, in order, with the first command of the ''path()'' function interpolating with the
	initial <<coordinate-pair>> in the ''shape()'' function.

		Note: The first command of a ''path()'' function is guaranteed to be a ''move'', see <a href="https://www.w3.org/TR/SVG2/paths.html#PathDataMovetoCommands">moveTo</a> in the SVG spec.

	If the starting and ending values are both ''path()'' functions,
	the interpolated value is a ''path()'' function;
	otherwise it's a ''shape()'' function.
	In either case,
	the interpolated value must represent the same list of path data commands,
	with each command having its numerical components interpolated between the corresponding components of the starting and ending list.

	For this purpose, commands are "the same" if they use the same command keyword,
	and use the same <<by-to>> keyword.
	For ''curve'' and ''smooth'', they also must have the same number of control points.

	If an ''arc'' command has different <<arc-sweep>> between its starting and ending list,
	then the interpolated result uses ''cw'' for any progress value between 0 and 1.
	If it has different <<arc-size>> keywords,
	then the interpolated result uses ''large'' for any progress value between 0 and 1.

	Note: The ''arc'' keyword interpolation rules
	are meant to match existing SVG <{path}> interpolation rules.

<h3 id='basic-shape-computed-values'>
Computed Values of Basic Shapes</h3>

	The values in a <<basic-shape>> function are computed as specified, with these exceptions:

	<ul>
		<li>
			Omitted values are included and compute to their defaults.

		<li>
			A <<position>> value in ''circle()'' or ''ellipse()'' is computed as a pair of offsets (horizontal then vertical) from the top left origin, each given as a <<length-percentage>>.

		<li>
			A <<'border-radius'>> value in a <<basic-shape-rect>> function
			is computed as an expanded list of all eight <<length-percentage>> values.

		<li>
			All <<basic-shape-rect>> functions compute to the equivalent ''inset()'' function.

			Note: Given ''rect(t r b l)'',
			the equivalent function is ''inset(t calc(100% - r) calc(100% - b) l)''.
			Given ''xywh(x y w h)'',
			the equivalent function is ''inset(y calc(100% - x - w) calc(100% - y - h) x)''.
	</ul>

	<wpt>
		parsing/shape-image-threshold-computed.html
		parsing/shape-margin-computed.html
		parsing/shape-outside-computed.html
		shape-functions/circle-function-computed.html
		shape-functions/ellipse-function-computed.html
		shape-functions/inset-function-computed.html
		shape-functions/path-function-computed.html
		shape-functions/polygon-function-computed.html
		shape-functions/rect-function-computed.html
		shape-functions/xywh-function-computed.html
		shape-outside/values/shape-outside-computed-shape-000.html
		shape-outside/values/shape-outside-computed-shape-001.html
	</wpt>

<h3 id='basic-shape-serialization'>
Serialization of Basic Shapes</h3>

	To serialize the <<basic-shape>> functions,
	serialize as per their individual grammars,
	in the order the grammars are written in,
	joining space-separated tokens with a single space,
	and following each serialized comma with a single space.
	For serializing [=computed values=],
	component values are [=computed value|computed=],
	and omitted when possible without changing the meaning.


	<div class="example">

		As [=specified value=] serialization of the shape functions are relatively trivial,
		here are some examples of [=computed value=] serializations
		for ''circle()'' notations when used in 'shape-outside':

		* <<position>> [[css-values-4#position-serialization|serialization rules]] mean that
			keywords [=computed value|compute to=] percentages,
			and serialize in horizontal-vertical order.

			<pre><code>
			circle(at bottom left)
			/* serializes to */
			circle(at 0% 100%)
			</code></pre>

		* Omitting optional components means that
			default values do not show up in the serialization.

			<pre><code>
			circle(closest-side at center)
			/* serializes to */
			circle()
			</code></pre>

		* Value [[css-cascade-5#computed|computation]] means that
			some functions [[#basic-shape-computed-values|canonicalize to a different form]].

			<pre><code>
			rect(10px 20px 30px 40px)
			/* serializes to */
			inset(10px calc(100% - 20px) calc(100% - 30px) 40px)
			</code></pre>
	</div>

	<wpt>
		basic-shape-circle-ellipse-serialization.html
	</wpt>


<h3 id='basic-shape-interpolation'>
Interpolation of Basic Shapes</h3>

	For interpolating between
	one basic shape and a second,
	the rules below are applied.
	The values in the shape functions interpolate
	<a href="https://www.w3.org/TR/web-animations-1/#by-computed-value">by computed value</a>.
	The list values interpolate as
	length, percentage, or calc where possible.
	If list values are not one of those types
	but are identical
	(such as finding ''nonzero''
	in the same list position
	in both lists)
	those values do interpolate.

	<ul>
		<li>
			Both shapes must use the same <a>reference box</a>.
		</li>
		<li>
			If both shapes are the same type,
			that type is ''ellipse()'' or ''circle()'',
			and the radiuses are specified as <<length-percentage>>
			(rather than keywords),
			interpolate between each value
			in the shape functions.
		</li>
		<li>
			If both shapes are of type ''inset()'',
			interpolate between each value
			in the shape functions.
		</li>
		<li>
			If both shapes are of type ''polygon()'',
			both polygons have the same number of vertices,
			and use the same <<'fill-rule'>>,
			interpolate between each value
			in the shape functions.
		</li>
		<li>
			In all other cases no interpolation is specified.
		</li>
	</ul>

	<wpt>
		animation/shape-image-threshold-interpolation.html
		animation/shape-margin-composition.html
		animation/shape-margin-interpolation.html
		animation/shape-outside-composition.html
		animation/shape-outside-interpolation.html
		basic-shape-interpolation.html
	</wpt>

<h2 id="shapes-from-image">
Shapes from Image</h2>

	Another way of defining shapes
	is by specifying a source <<image>>
	whose alpha channel is used
	to compute the shape.
	The shape is computed to be the path or paths
	that enclose the area(s)
	where the opacity of the specified image
	is greater than the 'shape-image-threshold' value.
	The absence of any pixels with an alpha value
	greater than the specified threshold
	results in an empty float area that will not affect wrapping.
	If the 'shape-image-threshold' is not specified,
	the initial value to be considered is 0.0.

	The image is sized and positioned
	as if it were a replaced element
	whose specified width and height
	are the same as the element's
	used content box size.

	For animated raster image formats (such as
	<a href="http://www.w3.org/Graphics/GIF/spec-gif89a.txt">GIF</a>),
	the first frame of the animation sequence is used.

	<div class="example">

	An image is floating to the left of a paragraph.
	The image shows the 3D version of the
	CSS logo over a transparent background.
	The logo has a shadow using an alpha-channel.

	The image defines its <a>float area</a>
	through the 'shape-outside' property.

	<pre>
		<code>
			&lt;p&gt;
				&lt;img id="CSSlogo" src="CSS-logo1s.png"/&gt;
				blah blah blah blah...
			&lt;/p&gt;

			&lt;style&gt;
				#CSSlogo {
					float: left;
					shape-outside: attr(src url);
					shape-image-threshold: 0.1;
				}
			&lt;/style&gt;
		</code>
	</pre>

	The 'shape-outside' property re-uses the url
	from the src attribute of the img element.

	It is perfectly possible to display an image
	and use a different image for its <a>float area</a>.

	In the figure below, the alpha-channel threshold
	is represented by the dotted line around the CSS logo.

	It's then possible to affect where the lines
	of the paragraph start in three ways:

	<ol>
		<li>Modifying the alpha channel in the image</li>
		<li>Changing the value of the 'shape-image-threshold' property</li>
		<li>Changing the value of the 'shape-margin' property (see example 8)</li>
	</ol>

		<figure>
			<img alt="A float shape around an image using its alpha-channel" src="images/shape-outside-image.png" style="width:70%">
			<figcaption>
				A float shape around an image using its alpha-channel.
			</figcaption>
		</figure>
	</div>

	<wpt>
		animation/shape-image-threshold-interpolation.html
		parsing/shape-image-threshold-computed.html
		parsing/shape-image-threshold-invalid.html
		parsing/shape-image-threshold-valid.html
		shape-outside/assorted/float-retry-push-image.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-001.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-002.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-003.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-004.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-005.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-006.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-007.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-008.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-009.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-010.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-011.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-012.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-013.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-014.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-015.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-016.html
		shape-outside/shape-image/gradients/shape-outside-radial-gradient-001.html
		shape-outside/shape-image/gradients/shape-outside-radial-gradient-002.html
		shape-outside/shape-image/gradients/shape-outside-radial-gradient-003.html
		shape-outside/shape-image/gradients/shape-outside-radial-gradient-004.html
		shape-outside/shape-image/shape-image-000.html
		shape-outside/shape-image/shape-image-001.html
		shape-outside/shape-image/shape-image-002.html
		shape-outside/shape-image/shape-image-003.html
		shape-outside/shape-image/shape-image-004.html
		shape-outside/shape-image/shape-image-005.html
		shape-outside/shape-image/shape-image-006.html
		shape-outside/shape-image/shape-image-007.html
		shape-outside/shape-image/shape-image-008.html
		shape-outside/shape-image/shape-image-009.html
		shape-outside/shape-image/shape-image-010.html
		shape-outside/shape-image/shape-image-011.html
		shape-outside/shape-image/shape-image-012.html
		shape-outside/shape-image/shape-image-013.html
		shape-outside/shape-image/shape-image-014.html
		shape-outside/shape-image/shape-image-015.html
		shape-outside/shape-image/shape-image-016.html
		shape-outside/shape-image/shape-image-017.html
		shape-outside/shape-image/shape-image-018.html
		shape-outside/shape-image/shape-image-019.html
		shape-outside/shape-image/shape-image-020.html
		shape-outside/shape-image/shape-image-021.html
		shape-outside/shape-image/shape-image-022.html
		shape-outside/shape-image/shape-image-023.html
		shape-outside/shape-image/shape-image-024.html
		shape-outside/shape-image/shape-image-025.html
		shape-outside/shape-image/shape-image-026.html
		shape-outside/shape-image/shape-image-027.html
		shape-outside/shape-image/shape-image-028.html
		shape-outside/shape-image/shape-image-029.html
	</wpt>

<h2 id="shapes-from-box-values">
Shapes from Box Values</h2>

	Shapes can be defined
	by reference to edges in the
	<a href="https://www.w3.org/TR/css-box-3/#box-model">CSS Box Model</a>.
	These edges include
	<a href="https://www.w3.org/TR/css3-background/#corner-shaping">border-radius curvature</a> [[!CSS3BG]]
	from the used border-radius values.
	The <<shape-box>> value extends the <<visual-box>> value
	to include ''margin-box''.
	Its syntax is:

	<pre class="prod">
		<dfn><<shape-box>></dfn> = <<visual-box>> | <a data-xref-type="css-value" data-xref-for="<shape-box>">margin-box</a> | <a data-xref-type="css-value" data-xref-for="<shape-box>">half-border-box</a>
	</pre>

	The definitions of the values are:

	The <dfn value for="<shape-box>, shape-outside">margin-box</dfn> value defines the shape
	enclosed by the outside margin edge.
	The corner radii of this shape are determined
	by the corresponding border-radius and margin values.
	If the ratio of <code>border-radius/margin</code> is 1 or more, 
	or margin is negative or zero, 
	then the margin box corner radius is
	<code>max(border-radius + margin, 0)</code>.
	The margin box's corners are [=outset-adjusted border radius|outset-adjusted=] given the element's [=border box=], 'border-radius', and the margin.

	The <dfn value for="<shape-box>, shape-outside">border-box</dfn> value defines the shape
	enclosed by the outside border edge.
	This shape follows all
	of the normal border radius shaping rules
	for the outside of the border.

	The <dfn value for="<shape-box>, shape-outside">padding-box</dfn> value defines the shape
	enclosed by the outside padding edge.
	This shape follows all
	of the normal border radius shaping rules
	for the inside of the border.

	The <dfn value for="<shape-box>, shape-outside">content-box</dfn> value defines the shape
	enclosed by the outside content edge.
	Each corner radius of this box
	is the larger of 0
	or <code>border-radius - border-width - padding</code>.

	The <dfn value for="<shape-box>, shape-outside">half-border-box</dfn> value defines the shape
	enclosed by a box that is in the middle between the ''padding-box'' and the ''border-box''.

	<div class="example">

		Given the 100px square below with
		10px padding, border and margins,
		the box values define these shapes:

		<ul>
			<li>''margin-box'': the shape containing all of the yellow pixels</li>
			<li>''border-box'': the shape containing all of the black pixels</li>
			<li>''padding-box'': the shape containing all of the mauve pixels</li>
			<li>''content-box'': the shape containing all of the blue pixels</li>
		</ul>

		<figure>
			<img alt="Colored boxes representing simple box edges" src="images/box-edges-simple.png">
			<figcaption>
				Simple CSS Box Model Edges
			</figcaption>
		</figure>

		And the same definitions apply to a more complex example with the same 100px square, but with these border, padding and margin properties:

		<pre>
			<code>
				border-radius: 20px 20px 20px 40px;
				border-width: 30px 10px 20px 10px;
				padding: 10px 20px 10px 10px;
				margin: 20px 10px 10px 10px;
			</code>
		</pre>

		<figure>
			<img alt="Colored boxes representing complex box edges" src="images/box-edges-complex.png">
			<figcaption>
				Complex CSS Box Model Edges
			</figcaption>
		</figure>
	</div>

	<div class="example">

		The difference between normal float wrapping
		and wrapping around the shape defined
		by the margin-box value is that
		the margin-box shape includes corner shaping.
		Take the 100px square with 10px padding,
		border and margins,
		but with a border-radius of 60px.
		If you make a left float out of it,
		content normally wraps in this manner:

		<figure>
			<img alt="Text wrapping around float with no shape" src="images/normal-wrap.png">
			<figcaption>
				Normal float wrapping
			</figcaption>
		</figure>

		If you add a margin-box shape to the float,
		then content wraps around the rounded margin-box corners.

		<pre>
			<code>
				shape-outside: margin-box;
			</code>
		</pre>

		<figure>
			<img alt="Text wrapping around float with margin-box shape" src="images/margin-box-wrap.png">
			<figcaption>
				Float wrapping with margin-box
			</figcaption>
		</figure>
	</div>

	<wpt>
		shape-outside/shape-box/shape-outside-border-box-001.html
		shape-outside/shape-box/shape-outside-border-box-002.html
		shape-outside/shape-box/shape-outside-border-box-003.html
		shape-outside/shape-box/shape-outside-border-box-border-radius-001.html
		shape-outside/shape-box/shape-outside-border-box-border-radius-002.html
		shape-outside/shape-box/shape-outside-border-box-border-radius-003.html
		shape-outside/shape-box/shape-outside-border-box-border-radius-004.html
		shape-outside/shape-box/shape-outside-border-box-border-radius-005.html
		shape-outside/shape-box/shape-outside-border-box-border-radius-006.html
		shape-outside/shape-box/shape-outside-border-box-border-radius-007.html
		shape-outside/shape-box/shape-outside-border-box-border-radius-008.html
		shape-outside/shape-box/shape-outside-border-box-border-radius-009.html
		shape-outside/shape-box/shape-outside-border-box-border-radius-010.html
		shape-outside/shape-box/shape-outside-border-box-border-radius-011.html
		shape-outside/shape-box/shape-outside-border-box-border-radius-012.html
		shape-outside/shape-box/shape-outside-box-002.html
		shape-outside/shape-box/shape-outside-box-003.html
		shape-outside/shape-box/shape-outside-box-004.html
		shape-outside/shape-box/shape-outside-box-006.html
		shape-outside/shape-box/shape-outside-box-007.html
		shape-outside/shape-box/shape-outside-box-008.html
		shape-outside/shape-box/shape-outside-box-009.html
		shape-outside/shape-box/shape-outside-content-box-001.html
		shape-outside/shape-box/shape-outside-content-box-002.html
		shape-outside/shape-box/shape-outside-content-box-003.html
		shape-outside/shape-box/shape-outside-content-box-border-radius-001.html
		shape-outside/shape-box/shape-outside-content-box-border-radius-002.html
		shape-outside/shape-box/shape-outside-margin-box-001.html
		shape-outside/shape-box/shape-outside-margin-box-002.html
		shape-outside/shape-box/shape-outside-margin-box-border-radius-001.html
		shape-outside/shape-box/shape-outside-margin-box-border-radius-002.html
		shape-outside/shape-box/shape-outside-margin-box-border-radius-003.html
		shape-outside/shape-box/shape-outside-margin-box-border-radius-004.html
		shape-outside/shape-box/shape-outside-margin-box-border-radius-005.html
		shape-outside/shape-box/shape-outside-margin-box-border-radius-006.html
		shape-outside/shape-box/shape-outside-margin-box-border-radius-007.html
		shape-outside/shape-box/shape-outside-margin-box-border-radius-008.html
		shape-outside/shape-box/shape-outside-padding-box-001.html
		shape-outside/shape-box/shape-outside-padding-box-002.html
		shape-outside/shape-box/shape-outside-padding-box-003.html
		shape-outside/shape-box/shape-outside-padding-box-border-radius-001.html
		shape-outside/shape-box/shape-outside-padding-box-border-radius-002.html
		shape-outside/values/shape-outside-box-000.html
		shape-outside/values/shape-outside-shape-box-pair-000.html
	</wpt>

<h2 id="declaring-shapes">
Declaring Shapes</h2>

	Shapes are declared with
	the 'shape-outside' property,
	with possible modifications
	from the 'shape-margin' property.
	The shape defined by
	the 'shape-outside'
	and 'shape-margin' properties
	changes the geometry
	of a float element's
	<a>float area</a>.

<h3 id="shape-outside-property">
Float Area Shape: the 'shape-outside' property</h3>

	<pre class='propdef'>
		Name: shape-outside
		Value: none | [ <<basic-shape>> || <<shape-box>> ] | <<image>>
		Initial: none
		Applies to: floats and [=initial letter boxes=]
		Inherited: no
		Computed value: as <a href="#basic-shape-computed-values">defined</a> for <<basic-shape>> (with <<shape-box>> following, if supplied); else the computed <<image>>; else the keyword as specified
		Animation type: as <a href="#basic-shape-interpolation">defined</a> for <<basic-shape>>, otherwise discrete
	</pre>

		The values of this property have the following meanings:

	<dl dfn-type="value" dfn-for="shape-outside">
		<dt><dfn>none</dfn></dt>
		<dd>
			The <a>float area</a> is unaffected.
		</dd>

		<dt><<shape-box>></dt>
		<dd>
			If one of these values is specified by itself
			the shape is computed based on one of
			''margin-box'',
			''border-box'',
			''padding-box'' or
			''content-box''
			which use their respective boxes
			including curvature from border-radius,
			similar to 'background-clip' [[!CSS3BG]].
		</dd>

		<dt><dfn><<basic-shape>></dfn></dt>
		<dd>
			The shape is computed based on one of the <<basic-shape>> functions. If a <<shape-box>> is also supplied, this defines the <a>reference box</a> for the <<basic-shape>> function. If <<shape-box>> is not supplied, then the <a>reference box</a> defaults to ''margin-box''.
		</dd>

		<dt><dfn><<image>></dfn></dt>
		<dd>
			The shape is extracted
			and computed based
			on the alpha channel
			of the specified <<image>>
			as defined by 'shape-image-threshold'.

			User agents must use the
			<!-- <a href="https://www.w3.org/TR/html5/infrastructure.html#cors-enabled-fetch">potentially CORS-enabled fetch</a>
			method defined by the [[!HTML5]] specification -->
			<a href="https://fetch.spec.whatwg.org/#http-cors-protocol">CORS protocol</a>
			defined by the [[!FETCH]] specification
			for all URLs in a 'shape-outside' value.
			When fetching,
			user agents must use "Anonymous" mode,
			set the referrer source
			to the stylesheet's URL
			and set the origin to the URL
			of the containing document.
			If this results in network errors
			such that there is no valid fallback image,
			the effect is as if
			the value <a value for="shape-outside">none</a>
			had been specified.
		</dd>
	</dl>

	<wpt>
		animation/shape-outside-composition.html
		animation/shape-outside-interpolation.html
		inheritance.html
		parsing/shape-outside-computed.html
		parsing/shape-outside-invalid-position.html
		parsing/shape-outside-valid-position.html
		shape-outside-infinite-crash.html
		shape-outside-invalid-001.html
		shape-outside-invalid-circle-000.html
		shape-outside-invalid-circle-001.html
		shape-outside-invalid-circle-002.html
		shape-outside-invalid-circle-003.html
		shape-outside-invalid-ellipse-001.html
		shape-outside-invalid-ellipse-002.html
		shape-outside-invalid-ellipse-003.html
		shape-outside-invalid-ellipse-004.html
		shape-outside-invalid-ellipse-005.html
		shape-outside-invalid-ellipse-006.html
		shape-outside-invalid-inset-001.html
		shape-outside-invalid-inset-002.html
		shape-outside-invalid-inset-003.html
		shape-outside-invalid-inset-004.html
		shape-outside/assorted/float-retry-push-circle.html
		shape-outside/assorted/float-retry-push-image.html
		shape-outside/assorted/float-retry-push-inset.html
		shape-outside/assorted/float-retry-push-polygon.html
		shape-outside/assorted/float-should-push.html
		shape-outside/shape-box/shape-outside-border-box-001.html
		shape-outside/shape-box/shape-outside-border-box-002.html
		shape-outside/shape-box/shape-outside-border-box-003.html
		shape-outside/shape-box/shape-outside-border-box-border-radius-001.html
		shape-outside/shape-box/shape-outside-border-box-border-radius-002.html
		shape-outside/shape-box/shape-outside-border-box-border-radius-003.html
		shape-outside/shape-box/shape-outside-border-box-border-radius-004.html
		shape-outside/shape-box/shape-outside-border-box-border-radius-005.html
		shape-outside/shape-box/shape-outside-border-box-border-radius-006.html
		shape-outside/shape-box/shape-outside-border-box-border-radius-007.html
		shape-outside/shape-box/shape-outside-border-box-border-radius-008.html
		shape-outside/shape-box/shape-outside-border-box-border-radius-009.html
		shape-outside/shape-box/shape-outside-border-box-border-radius-010.html
		shape-outside/shape-box/shape-outside-border-box-border-radius-011.html
		shape-outside/shape-box/shape-outside-border-box-border-radius-012.html
		shape-outside/shape-box/shape-outside-box-002.html
		shape-outside/shape-box/shape-outside-box-003.html
		shape-outside/shape-box/shape-outside-box-004.html
		shape-outside/shape-box/shape-outside-box-006.html
		shape-outside/shape-box/shape-outside-box-007.html
		shape-outside/shape-box/shape-outside-box-008.html
		shape-outside/shape-box/shape-outside-box-009.html
		shape-outside/shape-box/shape-outside-content-box-001.html
		shape-outside/shape-box/shape-outside-content-box-002.html
		shape-outside/shape-box/shape-outside-content-box-003.html
		shape-outside/shape-box/shape-outside-content-box-border-radius-001.html
		shape-outside/shape-box/shape-outside-content-box-border-radius-002.html
		shape-outside/shape-box/shape-outside-margin-box-001.html
		shape-outside/shape-box/shape-outside-margin-box-002.html
		shape-outside/shape-box/shape-outside-margin-box-border-radius-001.html
		shape-outside/shape-box/shape-outside-margin-box-border-radius-002.html
		shape-outside/shape-box/shape-outside-margin-box-border-radius-003.html
		shape-outside/shape-box/shape-outside-margin-box-border-radius-004.html
		shape-outside/shape-box/shape-outside-margin-box-border-radius-005.html
		shape-outside/shape-box/shape-outside-margin-box-border-radius-006.html
		shape-outside/shape-box/shape-outside-margin-box-border-radius-007.html
		shape-outside/shape-box/shape-outside-margin-box-border-radius-008.html
		shape-outside/shape-box/shape-outside-padding-box-001.html
		shape-outside/shape-box/shape-outside-padding-box-002.html
		shape-outside/shape-box/shape-outside-padding-box-003.html
		shape-outside/shape-box/shape-outside-padding-box-border-radius-001.html
		shape-outside/shape-box/shape-outside-padding-box-border-radius-002.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-001.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-002.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-003.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-004.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-005.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-006.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-007.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-008.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-009.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-010.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-011.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-012.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-013.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-014.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-015.html
		shape-outside/shape-image/gradients/shape-outside-linear-gradient-016.html
		shape-outside/shape-image/gradients/shape-outside-radial-gradient-001.html
		shape-outside/shape-image/gradients/shape-outside-radial-gradient-002.html
		shape-outside/shape-image/gradients/shape-outside-radial-gradient-003.html
		shape-outside/shape-image/gradients/shape-outside-radial-gradient-004.html
		shape-outside/shape-image/shape-image-000.html
		shape-outside/shape-image/shape-image-001.html
		shape-outside/shape-image/shape-image-002.html
		shape-outside/shape-image/shape-image-003.html
		shape-outside/shape-image/shape-image-004.html
		shape-outside/shape-image/shape-image-005.html
		shape-outside/shape-image/shape-image-006.html
		shape-outside/shape-image/shape-image-007.html
		shape-outside/shape-image/shape-image-008.html
		shape-outside/shape-image/shape-image-009.html
		shape-outside/shape-image/shape-image-010.html
		shape-outside/shape-image/shape-image-011.html
		shape-outside/shape-image/shape-image-012.html
		shape-outside/shape-image/shape-image-013.html
		shape-outside/shape-image/shape-image-014.html
		shape-outside/shape-image/shape-image-015.html
		shape-outside/shape-image/shape-image-016.html
		shape-outside/shape-image/shape-image-017.html
		shape-outside/shape-image/shape-image-018.html
		shape-outside/shape-image/shape-image-019.html
		shape-outside/shape-image/shape-image-020.html
		shape-outside/shape-image/shape-image-021.html
		shape-outside/shape-image/shape-image-022.html
		shape-outside/shape-image/shape-image-023.html
		shape-outside/shape-image/shape-image-024.html
		shape-outside/shape-image/shape-image-025.html
		shape-outside/shape-image/shape-image-026.html
		shape-outside/shape-image/shape-image-027.html
		shape-outside/shape-image/shape-image-028.html
		shape-outside/shape-image/shape-image-029.html
		shape-outside/supported-shapes/circle/shape-outside-circle-013.html
		shape-outside/supported-shapes/circle/shape-outside-circle-014.html
		shape-outside/supported-shapes/circle/shape-outside-circle-015.html
		shape-outside/supported-shapes/circle/shape-outside-circle-016.html
		shape-outside/supported-shapes/circle/shape-outside-circle-017.html
		shape-outside/supported-shapes/circle/shape-outside-circle-018.html
		shape-outside/supported-shapes/circle/shape-outside-circle-019.html
		shape-outside/supported-shapes/circle/shape-outside-circle-020.html
		shape-outside/supported-shapes/circle/shape-outside-circle-021.html
		shape-outside/supported-shapes/circle/shape-outside-circle-022.html
		shape-outside/supported-shapes/circle/shape-outside-circle-024.html
		shape-outside/supported-shapes/circle/shape-outside-circle-025.html
		shape-outside/supported-shapes/circle/shape-outside-circle-026.html
		shape-outside/supported-shapes/circle/shape-outside-circle-027.html
		shape-outside/supported-shapes/circle/shape-outside-circle-028.html
		shape-outside/supported-shapes/circle/shape-outside-circle-029.html
		shape-outside/supported-shapes/circle/shape-outside-circle-030.html
		shape-outside/supported-shapes/circle/shape-outside-circle-031.html
		shape-outside/supported-shapes/circle/shape-outside-circle-032.html
		shape-outside/supported-shapes/circle/shape-outside-circle-033.html
		shape-outside/supported-shapes/circle/shape-outside-circle-034.html
		shape-outside/supported-shapes/circle/shape-outside-circle-035.html
		shape-outside/supported-shapes/circle/shape-outside-circle-036.html
		shape-outside/supported-shapes/circle/shape-outside-circle-037.html
		shape-outside/supported-shapes/circle/shape-outside-circle-038.html
		shape-outside/supported-shapes/circle/shape-outside-circle-041.html
		shape-outside/supported-shapes/circle/shape-outside-circle-042.html
		shape-outside/supported-shapes/circle/shape-outside-circle-043.html
		shape-outside/supported-shapes/circle/shape-outside-circle-044.html
		shape-outside/supported-shapes/circle/shape-outside-circle-047.html
		shape-outside/supported-shapes/circle/shape-outside-circle-048.html
		shape-outside/supported-shapes/circle/shape-outside-circle-049.html
		shape-outside/supported-shapes/circle/shape-outside-circle-050.html
		shape-outside/supported-shapes/circle/shape-outside-circle-051.html
		shape-outside/supported-shapes/circle/shape-outside-circle-052.html
		shape-outside/supported-shapes/circle/shape-outside-circle-053.html
		shape-outside/supported-shapes/circle/shape-outside-circle-054.html
		shape-outside/supported-shapes/circle/shape-outside-circle-055.html
		shape-outside/supported-shapes/circle/shape-outside-circle-056.html
		shape-outside/supported-shapes/circle/shape-outside-circle-integer-overflow-crash.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-013.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-014.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-015.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-016.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-017.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-018.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-019.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-020.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-021.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-022.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-023.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-024.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-025.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-030.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-031.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-032.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-033.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-034.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-035.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-036.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-037.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-038.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-039.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-040.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-041.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-042.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-043.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-044.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-045.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-046.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-047.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-048.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-049.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-050.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-051.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-052.html
		shape-outside/supported-shapes/ellipse/shape-outside-ellipse-integer-overflow-crash.html
		shape-outside/supported-shapes/inset/shape-outside-inset-010.html
		shape-outside/supported-shapes/inset/shape-outside-inset-011.html
		shape-outside/supported-shapes/inset/shape-outside-inset-012.html
		shape-outside/supported-shapes/inset/shape-outside-inset-013.html
		shape-outside/supported-shapes/inset/shape-outside-inset-014.html
		shape-outside/supported-shapes/inset/shape-outside-inset-015.html
		shape-outside/supported-shapes/inset/shape-outside-inset-016.html
		shape-outside/supported-shapes/inset/shape-outside-inset-017.html
		shape-outside/supported-shapes/inset/shape-outside-inset-020.html
		shape-outside/supported-shapes/inset/shape-outside-inset-021.html
		shape-outside/supported-shapes/inset/shape-outside-inset-022.html
		shape-outside/supported-shapes/inset/shape-outside-inset-023.html
		shape-outside/supported-shapes/inset/shape-outside-inset-024.html
		shape-outside/supported-shapes/inset/shape-outside-inset-025.html
		shape-outside/supported-shapes/inset/shape-outside-inset-026.html
		shape-outside/supported-shapes/inset/shape-outside-inset-027.html
		shape-outside/supported-shapes/inset/shape-outside-inset-028.html
		shape-outside/supported-shapes/inset/shape-outside-inset-029.html
		shape-outside/supported-shapes/inset/shape-outside-inset-030.html
		shape-outside/supported-shapes/inset/shape-outside-inset-031.html
		shape-outside/supported-shapes/inset/shape-outside-inset-refcrash.html
		shape-outside/supported-shapes/polygon/shape-outside-polygon-007.html
		shape-outside/supported-shapes/polygon/shape-outside-polygon-008.html
		shape-outside/supported-shapes/polygon/shape-outside-polygon-009.html
		shape-outside/supported-shapes/polygon/shape-outside-polygon-010.html
		shape-outside/supported-shapes/polygon/shape-outside-polygon-011.html
		shape-outside/supported-shapes/polygon/shape-outside-polygon-012.html
		shape-outside/supported-shapes/polygon/shape-outside-polygon-013.html
		shape-outside/supported-shapes/polygon/shape-outside-polygon-014.html
		shape-outside/supported-shapes/polygon/shape-outside-polygon-015.html
		shape-outside/supported-shapes/polygon/shape-outside-polygon-016.html
		shape-outside/supported-shapes/polygon/shape-outside-polygon-017.html
		shape-outside/supported-shapes/polygon/shape-outside-polygon-018.html
		shape-outside/supported-shapes/polygon/shape-outside-polygon-019.html
		shape-outside/supported-shapes/polygon/shape-outside-polygon-020.html
		shape-outside/supported-shapes/polygon/shape-outside-polygon-021.html
		shape-outside/supported-shapes/polygon/shape-outside-polygon-022.html
		shape-outside/supported-shapes/polygon/shape-outside-polygon-023.html
		shape-outside/supported-shapes/polygon/shape-outside-polygon-024.html
		shape-outside/supported-shapes/polygon/shape-outside-polygon-025.html
		shape-outside/supported-shapes/polygon/shape-outside-polygon-032.html
		shape-outside/supported-shapes/polygon/shape-outside-polygon-crash.html
		shape-outside/values/shape-image-threshold-000.html
		shape-outside/values/shape-image-threshold-001.html
		shape-outside/values/shape-image-threshold-002.html
		shape-outside/values/shape-image-threshold-003.html
		shape-outside/values/shape-margin-000.html
		shape-outside/values/shape-margin-001.html
		shape-outside/values/shape-margin-002.html
		shape-outside/values/shape-margin-003.html
		shape-outside/values/shape-margin-004.html
		shape-outside/values/shape-margin-005.html
		shape-outside/values/shape-outside-box-000.html
		shape-outside/values/shape-outside-circle-000.html
		shape-outside/values/shape-outside-circle-001.html
		shape-outside/values/shape-outside-circle-002.html
		shape-outside/values/shape-outside-circle-003.html
		shape-outside/values/shape-outside-circle-004.html
		shape-outside/values/shape-outside-circle-005.html
		shape-outside/values/shape-outside-circle-006.html
		shape-outside/values/shape-outside-circle-007.html
		shape-outside/values/shape-outside-circle-008.html
		shape-outside/values/shape-outside-circle-009.html
		shape-outside/values/shape-outside-circle-010.html
		shape-outside/values/shape-outside-circle-011.html
		shape-outside/values/shape-outside-computed-shape-000.html
		shape-outside/values/shape-outside-computed-shape-001.html
		shape-outside/values/shape-outside-ellipse-000.html
		shape-outside/values/shape-outside-ellipse-001.html
		shape-outside/values/shape-outside-ellipse-002.html
		shape-outside/values/shape-outside-ellipse-003.html
		shape-outside/values/shape-outside-ellipse-004.html
		shape-outside/values/shape-outside-ellipse-005.html
		shape-outside/values/shape-outside-ellipse-006.html
		shape-outside/values/shape-outside-ellipse-007.html
		shape-outside/values/shape-outside-ellipse-008.html
		shape-outside/values/shape-outside-ellipse-009.html
		shape-outside/values/shape-outside-ellipse-010.html
		shape-outside/values/shape-outside-ellipse-011.html
		shape-outside/values/shape-outside-inset-000.html
		shape-outside/values/shape-outside-inset-001.html
		shape-outside/values/shape-outside-inset-0010.html
		shape-outside/values/shape-outside-inset-002.html
		shape-outside/values/shape-outside-inset-003.html
		shape-outside/values/shape-outside-inset-004.html
		shape-outside/values/shape-outside-inset-005.html
		shape-outside/values/shape-outside-inset-006.html
		shape-outside/values/shape-outside-inset-007.html
		shape-outside/values/shape-outside-inset-008.html
		shape-outside/values/shape-outside-inset-009.html
		shape-outside/values/shape-outside-polygon-000.html
		shape-outside/values/shape-outside-polygon-001.html
		shape-outside/values/shape-outside-polygon-002.html
		shape-outside/values/shape-outside-polygon-003.html
		shape-outside/values/shape-outside-polygon-004.html
		shape-outside/values/shape-outside-polygon-005.html
		shape-outside/values/shape-outside-polygon-006.html
		shape-outside/values/shape-outside-shape-arguments-000.html
		shape-outside/values/shape-outside-shape-arguments-001.html
		shape-outside/values/shape-outside-shape-box-pair-000.html
		shape-outside/values/shape-outside-shape-inherit-000.html
		shape-outside/values/shape-outside-shape-initial-000.html
		shape-outside/values/shape-outside-shape-none-000.html
		shape-outside/values/shape-outside-shape-notation-000.html
		spec-examples/shape-outside-001.html
		spec-examples/shape-outside-002.html
		spec-examples/shape-outside-003.html
		spec-examples/shape-outside-004.html
		spec-examples/shape-outside-005.html
		spec-examples/shape-outside-006.html
		spec-examples/shape-outside-007.html
		spec-examples/shape-outside-008.html
		spec-examples/shape-outside-010.html
		spec-examples/shape-outside-011.html
		spec-examples/shape-outside-012.html
		spec-examples/shape-outside-013.html
		spec-examples/shape-outside-014.html
		spec-examples/shape-outside-015.html
		spec-examples/shape-outside-016.html
		spec-examples/shape-outside-017.html
		spec-examples/shape-outside-018.html
		spec-examples/shape-outside-019.html
	</wpt>

<h3 id="shape-image-threshold-property">
Choosing Image Pixels: the 'shape-image-threshold' property</h3>

	The 'shape-image-threshold'
	defines the alpha channel threshold
	used to extract the shape
	using an image.
	A value of 0.5 means that
	the shape will enclose
	all the pixels
	that are more than 50% opaque.

	<pre class='propdef'>
		Name: shape-image-threshold
		Value: <<opacity-value>>
		Initial: 0
		Applies to: floats
		Inherited: no
		Computed value: specified number, clamped to the range [0,1]
		Animation type: by computed value
	</pre>

	The values of this property have the following meanings:

	<dl dfn-type="value" dfn-for="shape-image-threshold">
		<dt><dfn><<number>></dfn></dt>
		<dd>
			Sets the threshold used
			for extracting a shape
			from an image.
			The shape is defined
			by the pixels whose alpha value
			is greater than the threshold.
			A threshold value outside the range
			0.0 (fully transparent)
			to 1.0 (fully opaque)
			will be clamped to this range.
		</dd>
	</dl>

	Note: A future level of CSS Shapes may define
	a switch to use the luminance data
	from an image instead of the alpha data.
	When this happens,
	shape-image-threshold will be extended
	to apply its threshold
	to either alpha or luminance,
	depending on the switch state.

	<wpt>
		animation/shape-image-threshold-interpolation.html
		inheritance.html
		parsing/shape-image-threshold-computed.html
		parsing/shape-image-threshold-invalid.html
		parsing/shape-image-threshold-valid.html
		shape-outside/values/shape-image-threshold-000.html
		shape-outside/values/shape-image-threshold-001.html
		shape-outside/values/shape-image-threshold-002.html
		shape-outside/values/shape-image-threshold-003.html
	</wpt>

<h3 id="shape-margin-property">
Expanding a Shape: the 'shape-margin' property</h3>

	The 'shape-margin' property adds
	a margin to a 'shape-outside'.
	This defines a new shape
	that is the smallest contour
	(in the shrink-wrap sense)
	that includes all the points
	that are the 'shape-margin' distance outward
	in the perpendicular direction
	from a point on the underlying shape. 
	This includes any edge or line sections 
	from the underlying shape.
	Note that at points where
	a perpendicular is not defined
	(e.g. sharp points or line ends)
	take all points
	on the circle centered at the point
	and with a radius of 'shape-margin'.

	The new shape produced by applying 'shape-outside' 
	is what determines the <a>float area</a>, 
	and must be constructed  
	before making any <a>wrap</a> decisions.

	This property takes only non-negative values.

	<pre class='propdef'>
		Name: shape-margin
		Value: <<length-percentage [0,∞]>>
		Initial: 0
		Applies to: floats and [=initial letter boxes=]
		Inherited: no
		Percentages: refer to the <a>inline size</a> of the containing block
		Computed value: computed <<length-percentage>> value
		Animation type: by computed value
	</pre>

	<dl dfn-type="value" dfn-for="shape-margin">
		<dt><dfn><<length-percentage [0,∞]>></dfn></dt>
		<dd>
			Sets the margin of the shape to the specified value.
	</dl>

	Note: Adding a shape-margin does NOT allow a float area 
	to extend outside a float's margin box. 
	Extra margin may need to be applied 
	along with shape-margin to avoid clipping.

	<div class="example">

		A 'shape-margin' creating an offset from a polygonal 'shape-outside'. 
		The lighter blue area shows the shape in a 100x100px float, 
		and the darker blue area shows the 10px offset.

		<pre>
			<code>
				.float {
				    width: 100px;
				    height: 100px;
					shape-outside: polygon(10px 10px, 90px 50px, 40px 50px, 90px 90px, 10px 90px);
					shape-margin: 10px;
				}
			</code>
		</pre>
		<img src="images/nepal-flag-shape.png"
			alt="Example of a shape-margin offset">
	</div>

	<div class="example">

		If shape-margin is added
		to the CSS logo from example 6,
		the line boxes <a>wrapping</a>
		around the shape are shortened further.
		In case the image’s alpha channel 
		runs up to the right edge of the image, 
		some extra margin-right should be applied 
		to ensure the shape is not clipped by the margin box.

		<pre>
			<code>
				#CSSlogo {
					shape-margin: 35px;
					margin-right: 35px;
				}
			</code>
		</pre>
		<figure>
			<img alt="A float shape around an image using its alpha-channel with a 35 pixels shape-margin"	src="images/shape-outside-image-with-margin.png" style="width:70%">
			<figcaption>
				A float shape around an image using its alpha-channel with a 35-pixel 'shape-margin'
			</figcaption>
		</figure>
	</div>

	<wpt>
		animation/shape-margin-composition.html
		animation/shape-margin-interpolation.html
		inheritance.html
		parsing/shape-margin-computed.html
		parsing/shape-margin-invalid.html
		parsing/shape-margin-valid.html
		shape-outside/shape-box/shape-outside-margin-box-001.html
		shape-outside/shape-box/shape-outside-margin-box-002.html
		shape-outside/shape-box/shape-outside-margin-box-border-radius-001.html
		shape-outside/shape-box/shape-outside-margin-box-border-radius-002.html
		shape-outside/shape-box/shape-outside-margin-box-border-radius-003.html
		shape-outside/shape-box/shape-outside-margin-box-border-radius-004.html
		shape-outside/shape-box/shape-outside-margin-box-border-radius-005.html
		shape-outside/shape-box/shape-outside-margin-box-border-radius-006.html
		shape-outside/shape-box/shape-outside-margin-box-border-radius-007.html
		shape-outside/shape-box/shape-outside-margin-box-border-radius-008.html
		shape-outside/values/shape-margin-000.html
		shape-outside/values/shape-margin-001.html
		shape-outside/values/shape-margin-002.html
		shape-outside/values/shape-margin-003.html
		shape-outside/values/shape-margin-004.html
		shape-outside/values/shape-margin-005.html
	</wpt>

	Privacy Considerations {#privacy}
	===============================================
	
		No privacy concerns have been raised against this specification.
	
	
	Security Considerations {#security}
	===============================================
	
		Since the <<image>> value of 'shape-outside' 
		can expose some image data in a new way, 
		use is limited to images with CORS approval.
	

<h2 class="no-num" id="acknowledgments">
Acknowledgments</h2>

	This specification is made possible by input from
	Tab Atkins Jr.,
	Amelia Bellamy-Royds,
	Oriol Brufau,
	Andrei Bucur,
	Alexandru Chiculita,
	Boris Chiou,
	Emilio Cobos Álvarez,
	Elika Etemad,
	Arron Eicholz,
	Sylvain Galineau,
	Daniel Glazman,
	Arno Gourdol,
	Zoltan Horvath,
	Chris Jones,
	Bem Jones-Bey,
	Ian Kilpatrick,
	Guillaume Lebas,
	Ting-Yu Lin,
	Eric Meyer,
	Marcus Mielke,
	Alex Mogilevsky,
	Hans Muller,
	Mihnea Ovidenie,
	Virgil Palanciuc,
	Noam Rosenthal,
	Robert Sanderson,
	Dirk Schulze,
	Jen Simmons,
	Peter Sorotokin,
	Bear Travis,
	Lea Verou,
	Eugene Veselov,
	Brad Werth,
	Stephen Zilles
	and the CSS Working Group members.

<h2 class="no-num" id="change-log">
Change Log</h2>

<h3 class="no-num" id="20250612">
	Since <a href="https://www.w3.org/TR/2025/CRD-css-shapes-1-20250612/">2 June 2025</a></h3>

	<ul>
		<!-- to 12 June 2025 -->
		<li>none</li>
	</ul>

<h3 class="no-num" id="20221115">
	Since <a href="https://www.w3.org/TR/2022/CRD-css-shapes-1-20221115/">15 November 2022</a></h3>

	<ul>
		<!-- to 4 June 2025 -->
		<!-- https://github.com/w3c/csswg-drafts/commits/main/css-shapes-1 -->
		<li>Added Web Platform Test annotations</li>
		<li>Changed fill-rule default for path() in SVG shapes</li>
		<li>Clarified shape-margin and float area interaction</li>
		<li>Added polygon rounding examples</li>
		<li>Included all basic shapes in property prose for <a href="https://github.com/w3c/csswg-drafts/issues/9728">issue #9728</a></li>
		<li>Added start of polygon vertex rounding</li>
		<li>Used opacity-value (the value) not opacity (the property) as value of shape-image-threshold for <a href="https://github.com/w3c/csswg-drafts/issues/8311">issue #8311</a></li>
		<li>Replaced &lt;alpha-value> with &lt;'opacity'></li>
		<li>Clarified that shape-outside applies to initial letter boxes for <a href="https://github.com/w3c/csswg-drafts/issues/5160">issue #5160</a></li>
		<li>Rebased ellipse()/circle() definitions on top of &lt;radial-size> from Images, for <a href="https://github.com/w3c/csswg-drafts/issues/824">issue #824</a></li>
		<li>Made it clear that the position defaulting can be overridden by other specs (like Motion).</li>
		<li>Targeted fix of shape serialization section, fixed examples, for <a href="https://github.com/w3c/csswg-drafts/issues/8695">issue #8695</a></li>
		<li>Fixed xywh() computed value for <a href="https://github.com/w3c/csswg-drafts/issues/9053">issue #9053</a></li>
		<li>Rewrote syntax with implicitly optional comma <a href="https://github.com/w3c/csswg-drafts/pull/9650">PR #9650</a></li>
		<li>Cleanup &lt;*-box> definitions  <a href="https://github.com/w3c/csswg-drafts/pull/9505">PR #9505</a></li>
		<li>Added range notation in property definitions</li>
		<li>Added vertex rounding for polygon() for <a href="https://github.com/w3c/csswg-drafts/issues/9843">issue #9843</a> </li>
		<li>Updated shape-outside prose to include all <<basic-shape>>s for <a href="https://github.com/w3c/csswg-drafts/issues/9728">issue #9728</a> </li>
		<li>Clarified the shape-margin contribution to float areas for <a href="https://github.com/w3c/csswg-drafts/issues/2949">issue #2949</a> </li>
		<li>Added fill-rule default handling for SVG shapes from <a href="https://github.com/w3c/csswg-drafts/issues/3468">issue #3468</a> </li>
		<li>Moved 'shape()' from level 2</li>
	</ul>

<h3 class="no-num" id="20140320">
Since <a href="https://www.w3.org/TR/2014/CR-css-shapes-1-20140320/">March 20th 2014</a></h3>
	<ul>
		<li>Clarified shape-margin computed value</li>
		<li>Clarified serialization of default position values, for <a href="https://github.com/w3c/csswg-drafts/issues/402">issue #402</a> </li>
		<li>Clarified empty circles and ellipses for <a href="https://github.com/w3c/csswg-drafts/issues/850">issue #850</a></li>
		<li>Dropped the "Media:" entry from propdef tables, as with all CSS modules</li>
		<li>Updated box model references from CSS 2 to CSS Box Model 3</li>
		<li>Updated Computed Value and Animation Type in propdef tables</li>
		<li>Clarified computed value of shape-outside property, for <a href="https://github.com/w3c/csswg-drafts/issues/4042">issue #4042</a></li>
		<li>Clarified that shape-image-threshold can take a percentage value, like any alpha value, for <a href="https://github.com/w3c/csswg-drafts/issues/4102">issue #4102</a> </li>
		<li>Moved path() back from level 2</li>
		<li>Added handling of negative margins for margin-box, for <a href="https://github.com/w3c/csswg-drafts/issues/675">issue #675</a></li>
		<li>Removed special-case serialization of position values, for <a href="https://github.com/w3c/csswg-drafts/issues/2301">issue #2301</a> </li>
		<li>Added clarifications to shape-margin examples</li>
		<li>Added margin=0 case for margin-box shape, for <a href="https://github.com/w3c/csswg-drafts/issues/675">issue #675</a> </li>
		<li>Changed rules about degenerate shapes to use shape edges, for <a href="https://github.com/w3c/csswg-drafts/issues/2375">issue #2375</a> </li>
		<li>Clarified that invalid path strings make the ''path()'' invalid, for <a href="https://github.com/w3c/fxtf-drafts/issues/392">issue #392</a> </li>
		<li>Rewrote definition of inset rectangles, added auto value, added examples</li>
		<li>Clarified computed value of basic shape rect functions</li>
		<li>Assorted markup fixes, including use of range notation and exporting defined terms for use in other specifications</li>
		<li>Split Privacy and Security considerations into separate sections</li>
	</ul>

<h3 class="no-num" id="20140211">
Since <a href="https://www.w3.org/TR/2014/WD-css-shapes-1-20140211/">February 11th 2014</a></h3>
	<ul>
		<li>Replaced divs with images in the first example</li>
		<li>Add 0px to last serialization example</li>
	</ul>

<h3 class="no-num" id="20131203">
Since <a href="https://www.w3.org/TR/2013/WD-css-shapes-1-20131203/">December 3rd 2013</a></h3>
	<ul>
		<li>Updated computed value and serialization of basic shapes</li>
		<li>Added a margin-box example</li>
		<li>Change auto to none for shape-outside</li>
		<li>Defined shape-box instead of redefining box</li>
		<li>Clarified that shape from image may produce more than one path</li>
	</ul>

<h3 class="no-num" id="20130620">
Since <a href="https://www.w3.org/TR/2013/WD-css-shapes-1-20130620/">June 20th 2013</a></h3>
	<ul>
		<li>Added shape from box value section</li>
		<li>Updated basic-shape interpolation</li>
		<li>Allow negative insets, disallow negative radii</li>
		<li>Changed relevant to reference</li>
		<li>Remove box-sizing dependency, add relevant box keywords</li>
		<li>Changed circle() and ellipse() to use radial gradient syntax</li>
		<li>Postponed rectangle() to level 2</li>
		<li>Clarified shape-from-image sizing and positioning</li>
		<li>Change inset-rectangle() to inset()</li>
		<li>Future-proof shape-image-threshold to possibly apply to luminance</li>
		<li>Added CORS fetching to shape-outside URLs</li>
		<li>Changed shape-outside value from &lt;uri&gt; to &lt;image&gt;</li>
		<li>Remove 'percentages based on auto-sizing resolve to 0'</li>
		<li>Change initial value of shape-image-threshold to 0.0</li>
		<li>Change float positioning to be unaffected by shape-outside</li>
		<li>Shapes on floats clipped to float's margin box</li>
	</ul>

<h3 class="no-num" id="20120503">
Since <a href="https://www.w3.org/TR/2012/WD-css3-exclusions-20120503/">May 3rd 2012</a></h3>
	<ul>
		<li>Postpone shapes from SVG elements to a future Shapes level</li>
		<li>Postpone shape-inside to a future Shapes level</li>
		<li>split exclusions from shapes into separate modules</li>
		<li>added inset-rectangle() to basic shapes</li>
		<li>Changed shape-inside overflow diagrams to show exclusion behavior</li>
		<li>Changed shape-inside to contribute to the wrapping context</li>
		<li>Defined exclusion edges relative to wrapping content's writing mode</li>
		<li>Made use of start, end, before and after consistent</li>
		<li>Added interpolation for basic shapes</li>
		<li>Changed basic shapes to depend on box specified with box-sizing</li>
		<li>Added overflow behavior for shape-inside.</li>
		<li>Added wrap-flow:minimum.</li>
		<li>Clarified processing model.</li>
		<li>Changed wrap-margin and wrap-padding to shape-margin and shape-padding.</li>
		<li>Removed wrap shorthand.</li>
	</ul>

<h3 class="no-num" id="20111213">
Since <a href="https://www.w3.org/TR/2011/WD-css3-exclusions-20111213/">December 13th 2011</a></h3>
	<ul>
		<li>Clarified processing model.</li>
		<li>Clarified interaction with floats.</li>
		<li>Clarified that an exclusion element establishes a new block formatting context.</li>
	</ul>

